package com.hu.common.enums;

import java.util.Arrays;

/**
 * @author 00351634
 * @version 1.0
 * @date 2024/10/24 13:43
 * @description: 大屏周期枚举
 */
public enum PeriodEnum {
    YEAR("year", "年"),
    QUARTER("quarter", "季度"),
    MONTH("month", "月"),
    WEEK("week", "周"),
    ;

    private final String code;
    private final String comment;

    PeriodEnum(String code, String comment) {
        this.code = code;
        this.comment = comment;
    }

    public String getCode() {
        return code;
    }

    public String getComment() {
        return comment;
    }

    public static PeriodEnum of(String code) {
        return Arrays.stream(PeriodEnum.values()).filter(t -> t.getCode().equals(code)).findFirst().orElseThrow(() -> new IllegalArgumentException("不支持的周期类型"));
    }
}
